<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>面试题(每日一遍)7.4</title>
    <style>
       #box1{
        margin: 0 auto;
        width: 100px;
        height: 100px;
        background-color: red;
       }
       #box2{
        width: 100px;
        height: 100px;
        background-color: red;
        position: absolute;
        left: 50%;
        transform:translateX(-50%)
       }
       #box3{
        width: 100px;
        height: 100px;
        background-color: red;
        float: left;
        margin-left: 50%;
        transform: translateX(-50px);
       }
       #box4{
        width: 100px;
        height: 100px;
        background-color: red;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
       }
    </style>
</head>
<body>
   <div id="box1">水平居中1</div>
   <div id="box2">水平居中2</div><br/>
   <div id="box3">水平居中3</div>

   <div id="box4">垂直居中</div>
    <script>
        /**
         * 排序
         */
        //选择排序
        function xzsort(arr){
            for(let i=0;i<arr.length-1;i++){
                for(let j=i+1;j<arr.length;j++){
                    if(arr[i]<arr[j]){
                        let flag=arr[i];
                        arr[i]=arr[j];
                        arr[j]=flag;
                    }
                }
            }
            return arr;
        }
        //冒泡排序
        function mpsort(arr){
            for(let i=0;i<arr.length-1;i++){
                for(let j=0;j<arr.length-i-1;j++){
                    if(arr[j]<arr[j+1]){
                        let flag=arr[j];
                        arr[j]=arr[j+1];
                        arr[j+1]=flag;
                    }
                }
            }
            return arr;
        }
        let arr=[132,2,1,4,12,333]
        console.log('选择排序',xzsort(arr));
        console.log('冒泡排序',mpsort(arr));

        function klh(){
            let args=Array.prototype.slice.call(arguments);
            let inner=function(){
                args.push(...arguments)
                return inner;
            }
            inner.toString=function(){
                return args.reduce((prev,cur)=>{
                    return prev*cur;
                })
            }
            return inner;
        }
        console.log(parseInt(klh(1)(3)(5)))
    </script>
</body>
</html>